<?php

class ArticleTest extends BaseTest
{
    public function testInsert()
    {
        $class = new \Orm\Article\ArticleClass();
		$class['uid'] = $this->testNum();
		$class['title'] = $this->testStr();
		$class['remark'] = $this->testStr();
		$class['img'] = $this->testStr();


        $class->insert();
        $result_class = new \Orm\Article\ArticleClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['uid'],$result_class['uid']);
		$this->assertEquals($class['title'],$result_class['title']);
		$this->assertEquals($class['remark'],$result_class['remark']);
		$this->assertEquals($class['img'],$result_class['img']);

        return $result_class;
    }

    /**
     * @depends testInsert
     */
    public function testUpdate($class)
    {
		$class['uid'] = $this->testNum();
		$class['title'] = $this->testStr();
		$class['remark'] = $this->testStr();
		$class['img'] = $this->testStr();


        $class->update();
        $result_class = new \Orm\Article\ArticleClass();
        $result_class->loadById($class['id']);

		$this->assertEquals($class['uid'],$result_class['uid']);
		$this->assertEquals($class['title'],$result_class['title']);
		$this->assertEquals($class['remark'],$result_class['remark']);
		$this->assertEquals($class['img'],$result_class['img']);

        return $result_class;
    }

    /**
     * @depends testUpdate
     */

    public function testDelete($class)
    {
        $class->delete($class['id']);

        $result_class = new \Orm\Article\ArticleClass();
        $result_class->loadById($class['id']);
        $this->assertEquals(1, $result_class['is_del']);
        return $result_class;
    }


    /**
     * @depends testInsert
     */
    public static function testClean($class)
    {
        if ($class['id']) {
            $class->realDelete($class['id']);
        }
    }
}